﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../lib/html5.js"></script>
<script type="text/javascript" src="../lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>出入库管理</title>
    <style type="text/css">
        .auto-style1 {
            width: 40px;
        }
    </style>
</head>
<body>
    <div class="pd-5">
        <div class="text-c" id="findfdiv">
            <span class="select-box" style="width: 200px;">
                <select class="select" size="1" name="findtype" id="findtype">
                    <option value="">所有</option>
                    <option value="出库">出库</option>
                    <option value="入库">入库</option>
                </select>
            </span>
            <input type="text" name="finddataaddtime" id="finddataaddtime" style="width: 150px"  placeholder="处理日期" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="input-text Wdate" />
            <input type="text" class="input-text" style="width: 150px" placeholder="输入名称" id="findfv1" name="findfv1">
            <input type="text" class="input-text" style="width: 150px" placeholder="地块或者任务" id="finddctaskinfo" name="finddctaskinfo">
            <button onclick="findreolad()" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 查询</button>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-5">
            <span class="l">
                <!--    <a href="javascript:;" onclick="toolDelete()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 删除</a>-->
                <!--       <a href="javascript:;" onclick="toolUpdate()" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6df;</i> 修改</a>-->
                <!--                <a href="javascript:;" onclick="toolAdd()" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加</a>-->
                <a href="javascript:;" onclick="toolAdd('新增物品入库','StoreInOut-In-ae.html?action=add','','')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe645;</i>入库</a>
                <a href="javascript:;" onclick="toolAdd('新增物品出库','StoreInOut-Out-ae.html?action=add','','')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe644;</i>出库</a>
                <a href="javascript:;" onclick="toolAdd('物品作业出库','StoreInOut-OutWithWork-ae.html?action=add','','')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe644;</i>作业出库</a>
                <a href="javascript:;" onclick="showlist()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe687;</i> 查看明细</a>
            </span>
            <span class="r">操作提示：<strong>^_^</strong> </span>

        </div>
        <div class="mt-5 ml-20">
            <table class="table table-border table-bordered table-striped table-hover" id="tablelist" width="100%">
                <thead>
                    <tr class="text-c">
                        <th width="30"><a id="hcmtable_sall" onclick="hcmtable_sall();" href="javascript:;" title="全选反选"><i class="Hui-iconfont">&#xe608;全</i></a></th>
                        <th>类型</th>
                        <th>原由</th>
                        <th>操作人员</th>
                        <th>编号</th>
                        <th>状态</th>
                        <th>处理时间</th>
                        <th>明细</th><th>目标</th>
                        <th>操作</th>

                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>

        </div>
    </div>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="../lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../lib/datatables/1.10.0/jtable.js"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../js/hcui_list.js"></script>
    <script type="text/javascript">
        var remarkShowLength = 20;
        $(function () {
            spsetBaseNoBt("herp_inoutorder", "id", "herp_inoutorder as T", "*", "#tablelist", "herp_inoutorder", "出入库管理", "StoreInOut");
            hcmtable = $("#tablelist").DataTable({
                "serverSide": true,//服务端处理分页 无法使用当前查找
                "bFilter": false,  //是否使用内置的过滤功能
                "bInfo": true, "fnDrawCallback": function () { dTappendSkipPage(); },
                //"ajax": spselUrl(" and type=20150921"),
                "createdRow": function (row, data, dataIndex) {
                    if (data.dctaskinfo.length > remarkShowLength) {//只有超长，才有td点击事件
                        $(row).children('td').eq(8).attr('onclick', 'javascript:changeShowRemarks(this);');
                    }
                    $(row).children('td').eq(8).attr('content', data.dctaskinfo);
                },
                "ajax": {
                    "type": "POST",
                    "url": spselUrl(" and databranchid=" + HCUser.HCUorg, "*#herp_inoutorderlist#ordergid-@gid#") + "&sporderby= dataaddtime desc ",
                    "data": function (d) {
                        $("#findfdiv").find("input[type='text']").each(function () {
                            d[this.id] = $(this).val();
                        });
                        $("#findfdiv").find("select").each(function () {
                            d[this.id] = $(this).val();
                        });
                    }
                },
                "order": [[1, "desc"]],//默认第几个排序

                aLengthMenu: [10, 20, 50],
                "columns": [{ "data": "rowhcindex" }, { "data": "type" }, { "data": "sontype" }, { "data": "dataaddusername" }, { "data": "orderNo" }, { "data": "state" }, { "data": "dataaddtime" }, { "data": "id" }, { "data": "dctaskinfo" }, { "data": "id" }
                ],



                "columnDefs": [

                    //特殊显示列
                    //{
                    //    "targets": [6],
                    //    "render": function (data, type, row) {
                    //        if (data == "") return "";
                    //        else if (data == "保密") return "<span class=\"label radius\">" + data + "</span>";
                    //        else return "<span class=\"label label-success radius\">" + data + "</span>";
                    //    }
                    //}
                    //,
                   // 操作列
                    {
                        "targets": [9],
                        "render": function (data, type, row) {
                            console.log(row.type);
                            if (row.type == "入库") {
                                return "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolUpdateByIdCheckUrl('" + data + "','StoreInOut-In-ae.html','处理入库信息')\" href=\"javascript:;\" title=\"编辑\"><i class=\"Hui-iconfont\">&#xe6df;编辑</i></a> " +
                                       "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolDeleteThis('" + data + "','" + row.gid + "','" + row.type + "')\"     href=\"javascript:;\" title=\"删除\"><i class=\"Hui-iconfont\">&#xe6e2;删除</i></a>";
                            } if (row.type == "出库") {
                                return "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolUpdateByIdCheckUrl('" + data + "','StoreInOut-Out-ae.html','处理出库信息')\" href=\"javascript:;\" title=\"编辑\"><i class=\"Hui-iconfont\">&#xe6df;编辑</i></a> " +
                                       "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolDeleteThis('" + data + "','" + row.gid + "','" + row.type + "')\"     href=\"javascript:;\" title=\"删除\"><i class=\"Hui-iconfont\">&#xe6e2;删除</i></a>";
                            }
                            //"<a style=\"text-decoration:none\" onClick=\"toolUpdateById(" + data + ")\" href=\"javascript:;\" title=\"审核\">审核</a>" +
                        }
                    },
                    {
                        "targets": [7],
                        "render": function (data, type, row) {
                            var info = "";
                            row.subinfo.forEach(function (val, index) {
                                info += val.spname + "-数量:" + val.count + val.unit
                                    + "-批次:" + val.spbasepc
                                    + "-厂家:" + val.spbasecj+ "<br/>";
                            });

                            return info;

                        }
                    },
                     {
                         "targets": [8],
                         "render": function (data, type, row) {
                             if (row.dctaskinfo.length > remarkShowLength) {
                                 return getPartialRemarksHtml(row.dctaskinfo);//显示部分信息
                             } else {
                                 return row.dctaskinfo;//显示原始全部信息 }
                             }

                         }
                     },

                    //不排序
                   {
                       "orderable": false,
                       "targets": [0, 2, 3, 4, 5, 6, 7, 8, 9]
                   }
                  // ,
                  // //不显示
                  //{
                  //    "targets": [ 8],
                  //    "visible": false
                  //}

                ]
            });


            //$("#tablelist tbody").on("click", ".edit-btn", function () {
            //    var tds = $(this).parents("tr").children();
            //    $.each(tds, function (i, val) {
            //        var jqob = $(val);
            //        if (i < 1 || jqob.has('button').length) { return true; }//跳过第1项 序号,按钮
            //        var txt = jqob.text();
            //        var put = $("<input type='text' class=\"input-text\">");
            //        put.val(txt);
            //        jqob.html(put);
            //    });
            //    $(this).html("保存");
            //    $(this).toggleClass("edit-btn");
            //    $(this).toggleClass("save-btn");
            //});

            //$("#tablelist tbody").on("click", ".save-btn", function () {
            //    var row = hcmtable.row($(this).parents("tr"));
            //    var tds = $(this).parents("tr").children();
            //    $.each(tds, function (i, val) {
            //        var jqob = $(val);
            //        //把input变为字符串
            //        if (!jqob.has('button').length) {
            //            var txt = jqob.children("input").val();
            //            jqob.html(txt);
            //            hcmtable.cell(jqob).data(txt);//修改DataTables对象的数据
            //        }
            //    });
            //    var data = row.data();
            //    $.ajax({
            //        "url": "/example/resources/user_share/inline_edit_no_plugin/edit.php",
            //        "data": data,
            //        "type": "post",
            //        "error": function () {
            //            alert("服务器未正常响应，请重试");
            //        },
            //        "success": function (response) {
            //            alert(response);
            //        }
            //    });
            //    $(this).html("编辑");
            //    $(this).toggleClass("edit-btn");
            //    $(this).toggleClass("save-btn");
            //});

        });
        function showlist() {
            var index = layer.open({
                type: 2,
                title: "出入库明细",
                content: "StoreInOutLogList.html"
            });
            layer.full(index);
        }

        function toolDeleteThis(ID, gid, type) {
            if (ID.length == 0) {
                layer.alert('请选择要删除的内容');
                return;
            }
            var delurl;

            delurl = spdelUrl(ID);


            layer.confirm("确认要删除吗？记录数：" + 1, function (index) {
                var indexer = layer.load(2, {
                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                });

                $.get(delurl,
                 function (data) {
                     layer.close(indexer);
                     var data = JSON.parse(data);
                     switch (data.message) {
                         case JsonResult.SessionOut:
                             layer.msg('登录超时，请重新登录!', { icon: 2, time: 1000 });
                             break;
                         case JsonResult.Error:
                             layer.msg('系统出错!' + data.data, { icon: 2, time: 1000 });
                             break;
                         case JsonResult.Success:
                             layer.msg('已删除!', { icon: 1, time: 1000 });
                             hcui_ajaxasync = false;
                             if (type == "入库") {
                                 hcrainchange("", "herp_inoutorderlist", "dataisdeleted=1,hasout=count", "ordergid='" + gid + "'", function (data) {
                                     //没处理统计的库存-库存界面 初始化再处理
                                 });
                             }
                             if (type == "出库") {
                                 hcapipost("../api/Hcrain/OutStoreGoBack", { "id": gid }, function (data) { });
                             }
                             findreolad();
                             break;
                         default:
                             layer.msg('删除失败!' + data.message, { icon: 2, time: 1000 });
                             break;
                     }
                 });

            });
        }
        //》》》》》》》》》》》》》》》》》》》》》》》》展开 收缩
        //切换显示备注信息，显示部分或者全部
        function changeShowRemarks(obj) {//obj是td
            var content = $(obj).attr("content");
            if (content != null && content != '') {
                if ($(obj).attr("isDetail") == 'true') {//当前显示的是详细备注，切换到显示部分
                    //$(obj).removeAttr('isDetail');//remove也可以
                    $(obj).attr('isDetail', false);
                    $(obj).html(getPartialRemarksHtml(content));
                } else {//当前显示的是部分备注信息，切换到显示全部
                    $(obj).attr('isDetail', true);
                    $(obj).html(getTotalRemarksHtml(content));
                }
            }
        }
        //部分备注信息
        function getPartialRemarksHtml(remarks) {
            return remarks.substr(0, remarkShowLength) + '&nbsp;&nbsp;<a href="javascript:void(0);" ><b>......(展开)</b></a>';
        }

        //全部备注信息
        function getTotalRemarksHtml(remarks) {
            return remarks + '&nbsp;&nbsp;<a href="javascript:void(0);" ><b>(收起)</b></a>';
        }
        //》》》》》》》》》》》》》》》》》》》》》》》》展开 收缩
    </script>
</body>
</html>
